package com.sgb.kjwl.view.ui.adapter.transport;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.Html;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.GoodsSourceDetail;
import com.sgb.kjwl.model.entity.transport.GoodsOfferUnits;
import com.sgb.kjwl.model.entity.transport.GoodsSourcePlace;
import com.sgb.kjwl.model.entity.transport.SingleItemConstant;
import com.sgb.kjwl.model.entity.transport.SingleItemEntity;
import com.sgb.kjwl.model.entity.transport.common.AddressItem;
import com.sgb.kjwl.utils.CargoConstant;
import com.sgb.kjwl.utils.DefaultUtil;
import com.sgb.kjwl.utils.NumberUtil;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.transport.HandleAdressActivity;
import com.sgb.kjwl.view.ui.adapter.TransportInvoiceInfoAdapter;
import com.sgb.link.entity.LogisticsFlowLog;
import com.sgb.link.utils.LogisticsLogUtils;
import com.swgk.core.customview.SeeMoreView;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.util.ArrayUtil;
import com.swgk.core.util.SharedPreferenceUtil;

import java.util.ArrayList;
import java.util.List;

import static com.blankj.utilcode.util.ActivityUtils.startActivity;

/**
 * @Author : 熊丽
 * @date :2021/7/16 0016$ 10:49$
 * @Description ://竞价货源适配2.0.8新增$
 */
public class FreightPrjDetailAdapter extends BaseMultiItemQuickAdapter<GoodsSourceDetail, BaseViewHolder> implements GoodsDetailAddressAdapter.ItemOnClickListen{
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    private List<SingleItemEntity> mGoodsList;
    private OrderGoodsInfoAdapter mGoodsAdapter;
    private TransportInvoiceInfoAdapter adapter;
    private BiddingUnitAdapter mBiddingUnitAdapter;
    private Context mContext;
    private GoodsDetailAddressAdapter mAdapter;
    private List<GoodsOfferUnits> mList = new ArrayList<>();
    private ItemOnClickListen mItemOnClickListen;
    private GoodsSourceDetail mGoodsSourceDetail;
    private boolean isOwner=false;
    private boolean IsOrder=false;//是订单详情
    private boolean IsPersonalCenter;
    LogisticsFlowLog flowLog;
    public FreightPrjDetailAdapter(Context context, List<GoodsSourceDetail> data,boolean isOrder,boolean IsPersonalCenter) {
        super(data);
        this.mContext = context;
        this.mGoodsSourceDetail = data.get(0);
        this.IsOrder = isOrder;
        this.IsPersonalCenter = IsPersonalCenter;
        addItemType(SingleItemConstant.TYPE_ONE, R.layout.freight_information_item);
        addItemType(SingleItemConstant.TYPE_TWO, R.layout.activity_source_details_info);
        addItemType(SingleItemConstant.TYPE_THREE, R.layout.activity_source_details_info);
        addItemType(SingleItemConstant.TYPE_FOUR, R.layout.activity_source_details_info);
        addItemType(SingleItemConstant.TYPE_FIVE, R.layout.activity_source_details_info);
    }
    @Override
    protected void convert(BaseViewHolder helper, GoodsSourceDetail item) {
        if (item==null)return;
        mGoodsList = new ArrayList<>();
        switch (item.getItemType()){
            case SingleItemConstant.TYPE_ONE:
                initView(helper);
                helper.setVisible(R.id.rv_info,true);
                setProjectInformation( mGoodsList ,item,helper);
                break;
            case SingleItemConstant.TYPE_TWO:
                initView(helper);
                setQuotationRequirement( mGoodsList ,item);
                break;
            case SingleItemConstant.TYPE_THREE:
                initRecycler(helper);
                setSettlementRequirement( mGoodsList ,item);
                break;
            case SingleItemConstant.TYPE_FOUR:
                initView(helper);
                setOtherAgreements( mGoodsList ,item);
                break;
            case SingleItemConstant.TYPE_FIVE:
                mList=item.getGoodsOfferUnits();
                String companyNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NO, "");
                String userNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, "");
                if (companyNo.equals(item.getCompanyNo())||companyNo.equals(item.getTeamNo())||userNo.equals(item.getUserNo())){
                    isOwner = true;
                }else {
                    isOwner= false;
                }
                initBiddingView(helper,isOwner);
                break;
        }

    }

    private void initBiddingView(BaseViewHolder helper,boolean isOwner) {
        mBiddingUnitAdapter = new BiddingUnitAdapter(mList,isOwner,1);
        RecyclerView recyclerView = helper.itemView.findViewById(R.id.rv_info);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        mBiddingUnitAdapter.bindToRecyclerView(recyclerView);
        if (ArrayUtil.isNullOrEmpty(mList)) {
            View empty = LayoutInflater.from(mContext).inflate(R.layout.layout_logistics_null_list, recyclerView, false);
            mBiddingUnitAdapter.setEmptyView(empty);
        }
    }

    @Override
    public void onItemClick(GoodsSourcePlace place, String typeNo, int position) {
        mItemOnClickListen.onItemClick(place,typeNo,position);
        company=mGoodsSourceDetail.getTerminal()==3?"":mGoodsSourceDetail.getCompanyName();
        //TODO 去地图查看界面
        switch (typeNo){
            case "11":
                HandleAdressActivity.start(mContext,mGoodsSourceDetail.getContrcts(),company,mGoodsSourceDetail.getContrctsNumber(),mGoodsSourceDetail.getImAccount(),mGoodsSourceDetail.getPlace(),position,"11");
                break;
            case "12":
                HandleAdressActivity.start(mContext,mGoodsSourceDetail.getContrcts(),company,mGoodsSourceDetail.getContrctsNumber(),mGoodsSourceDetail.getImAccount(),mGoodsSourceDetail.getPlace(),position,"12");
                break;
            case "21":
                HandleAdressActivity.start(mContext,mGoodsSourceDetail.getContrcts(),company,mGoodsSourceDetail.getContrctsNumber(),mGoodsSourceDetail.getImAccount(),mGoodsSourceDetail.getPlace(),position,"21");
                break;
            case "22":
                HandleAdressActivity.start(mContext,mGoodsSourceDetail.getContrcts(),company,mGoodsSourceDetail.getContrctsNumber(),mGoodsSourceDetail.getImAccount(),mGoodsSourceDetail.getPlace(),position,"22");
                break;
        }
    }
    String company;
    public interface ItemOnClickListen {
        void onItemClick(GoodsSourcePlace place,String i,int position);
        void shipperCall(String tel);
        void receiveCall(String tel);

    }
    public void SetItemOnClickListen(ItemOnClickListen item){
        this.mItemOnClickListen = item;
    }
    private void initView(BaseViewHolder helper){
        mGoodsAdapter = new OrderGoodsInfoAdapter(mGoodsList,false);
        RecyclerView recyclerView = helper.itemView.findViewById(R.id.rv_info);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        mGoodsAdapter.bindToRecyclerView(recyclerView);
    }
    private void initRecycler(BaseViewHolder helper){
        adapter = new TransportInvoiceInfoAdapter(mGoodsList);
        RecyclerView recyclerView = helper.itemView.findViewById(R.id.rv_info);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        adapter.bindToRecyclerView(recyclerView);
    }
    private void setProjectInformation(List<SingleItemEntity> list, GoodsSourceDetail datas,BaseViewHolder helper){
        List<AddressItem> items = new ArrayList<>();
        if(datas.getPlace()!=null){
            initSettingItem(items,datas.getPlace(),datas.getHandleTypeNo());
            mAdapter = new GoodsDetailAddressAdapter(items,datas.getPlace());
            mAdapter.SetItemOnClickListen(this);
            RecyclerView recyclerView = helper.itemView.findViewById(R.id.rl_address);
            recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
            recyclerView.setAdapter(mAdapter);
        }
        helper.setVisible(R.id.bidding_order,true);
        helper.setText(R.id.info_fee, Html.fromHtml("<font size='12px' >运费单价：</font>" + ("<font  size='20px'>" + messagePrice(datas)+datas.getFreightUnitType() + "</font>")));
        helper.setText(R.id.info_freight,Html.fromHtml("<font size='12px' >运费合计：</font>" + ("<font  size='20px'>" + allFreight(helper,datas) + "</font>")));
        helper.setText(R.id.dingjia_type,"承运方式："+(TextUtils.isEmpty(datas.getPricingType())?"/":datas.getPricingType()));
        if (!TextUtils.isEmpty(datas.getHandleTypeName())){
            helper.setText(R.id.load_model,"装卸方式："+datas.getHandleTypeName());
            helper.setVisible(R.id.load_model,true);
        }else {
            helper.setVisible(R.id.load_model,false);
        }

        //设置内容
        SeeMoreView moreView = helper.getView(R.id.transport_ation_quire_text);
        moreView.setText(TextUtils.isEmpty(datas.getTransportationQuire())?"/":DefaultUtil.getString(datas.getTransportationQuire()));

        TextView loadPhoneValue = helper.getView(R.id.load_phone_value);
        TextView loadPeopleValue = helper.getView(R.id.load_people_value);
        TextView unloadPhoneValue = helper.getView(R.id.unload_phone_value);
        TextView unloadPeopleValue = helper.getView(R.id.unload_people_value);
        if (TextUtils.isEmpty(datas.getSendPeople())&& TextUtils.isEmpty(datas.getSendPhone())) {
            loadPeopleValue.setText("/");
        } else {
            loadPeopleValue.setText(datas.getSendPeople());
            loadPhoneValue.setText(datas.getSendPhone());
        }
        if (TextUtils.isEmpty(datas.getReceptionPeople())&& TextUtils.isEmpty(datas.getReceptionPhone())) {
            unloadPeopleValue.setText("/");
        } else {
            unloadPeopleValue.setText(datas.getReceptionPeople());
            unloadPhoneValue.setText(datas.getReceptionPhone());
        }

        if (TextUtils.isEmpty(datas.getSendPhone())) {
            loadPhoneValue.setCompoundDrawables(null, null, null, null);
        }
        if (TextUtils.isEmpty(datas.getReceptionPhone())) {
            unloadPhoneValue.setCompoundDrawables(null, null, null, null);
        }
        if ("1".equals(datas.getWhetherShow())){
            helper.getView(R.id.owner_information).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.owner_information).setVisibility(View.GONE);
        }
        helper.setText(R.id.tv_owner_unit_title_text,TextUtils.isEmpty(datas.getShipperOwnerUnit())?"/":datas.getShipperOwnerUnit());
        helper.setText(R.id.tv_owner_contact_title_text,TextUtils.isEmpty(datas.getShipperContact())?"/":datas.getShipperContact());
        helper.setText(R.id.tv_owner_contact_number_title_text,TextUtils.isEmpty(datas.getShipperPhone())?"/":datas.getShipperPhone());
        if (IsPersonalCenter) {
            loadPhoneValue.setCompoundDrawables(null, null, null, null);
            unloadPhoneValue.setCompoundDrawables(null, null, null, null);
            loadPhoneValue.setTextColor(mContext.getResources().getColor(R.color.FF333333));
            unloadPhoneValue.setTextColor(mContext.getResources().getColor(R.color.FF333333));
            loadPhoneValue.setClickable(false);
            unloadPeopleValue.setClickable(false);
        }
        loadPhoneValue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isLogin()) {
                    VerificationCodeLoginActivity.start(mContext);
                    return;
                }
                flowLog=new LogisticsFlowLog("4","装车对接人","icon");
                showConsignorDialog(datas.getSendPhone());
            }
        });
        unloadPhoneValue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isLogin()) {
                    VerificationCodeLoginActivity.start(mContext);
                    return;
                }
                flowLog=new LogisticsFlowLog("4","卸车对接人","icon");
                showConsignorDialog(datas.getReceptionPhone());
            }
        });
        list.clear();
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"项目名称",  (TextUtils.isEmpty(datas.getProjectName()) ? NumberUtil.trim0(datas.getWeight()) + "吨" + CargoConstant.getLastGoodsTypeName(datas.getGoodsTypeName(),datas.getSecondGoodsTypeName()) + "运输项目": datas.getProjectName())));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"项目地址", datas.getProjectAddress()==null?"/":TextUtils.isEmpty(datas.getProjectAddress().getAddress())?"/":datas.getProjectAddress().getAddress()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"项目描述",  TextUtils.isEmpty(datas.getProjectDesc())?"/":datas.getProjectDesc()+"  "));
    }

    private void setQuotationRequirement(List<SingleItemEntity> list, GoodsSourceDetail datas){
        list.clear();
        if (IsPersonalCenter){
            list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"报价资格", datas.getOfferType()==null?"/":datas.getOfferTypeWorlds(true)));
        }else {
            list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"报价资格", datas.getOfferType()==null?"/":datas.getOfferTypeWorlds(false)));
        }
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"注册资本", TextUtils.isEmpty(datas.getRegisteredMoney())?"/":String.valueOf(NumberUtil.trim0(NumberUtil.convertToDouble(datas.getRegisteredMoney())))+"万元"));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"车队规模", TextUtils.isEmpty(datas.getMotorcadeSize())?"/":datas.getMotorcadeSize()+"辆车以上"));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"运输资质", TextUtils.isEmpty(datas.getTransportationQualification())?"/":datas.getTransportationQualification()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"履约保证金", TextUtils.isEmpty(datas.getPerformanceBond())?"/": String.valueOf(NumberUtil.trim0(NumberUtil.convertToDouble(datas.getPerformanceBond())))+"元"));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"其他要求", TextUtils.isEmpty(datas.getOtherOfferRequire())?"/":datas.getOtherOfferRequire()+"  "));
    }
    private void setSettlementRequirement(List<SingleItemEntity> list, GoodsSourceDetail datas){
        list.clear();
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"发票要求", TextUtils.isEmpty(datas.getInvoiceWords())?"/":datas.getInvoiceWords().equals("不开发票") ? datas.getInvoiceWords():
                NumberUtil.trim0(datas.getTariff()) + "%" + datas.getInvoiceWords()));

        StringBuilder builder = new StringBuilder();

        String typeAx = "";
        if (!TextUtils.isEmpty(datas.getPrepaidProportion()) && !datas.getPrepaidProportion().equals("0")) {
            builder.append("预付款").append(datas.getPrepaidProportion()).append("%，");
        }
        if (datas.getPaymentAfterLoading() != 0) {
            builder.append("装车后支付").append(datas.getPaymentAfterLoading()).append("%，");
        }
        if (datas.getArrivalAcceptancePayment() != 0) {
            builder.append("到货验收后支付").append(datas.getArrivalAcceptancePayment()).append("%（尾款由验收人验收后支付），");
        }
        if (builder.length() > 1) {
            typeAx = builder.substring(0, builder.length() - 1);
        }
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_FOUR,"付款方式", TextUtils.isEmpty(datas.getPayType())?"/":datas.getPayType(), typeAx));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"货损约定", TextUtils.isEmpty(datas.getDamagePromise())?"/":(NumberUtil.trim0(NumberUtil.convertToDouble(datas.getDamagePromise())))+"吨"));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"货损赔偿", TextUtils.isEmpty(datas.getDamageCompensation())?"/":(NumberUtil.trim0(NumberUtil.convertToDouble(datas.getDamageCompensation())))+"元/吨"));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"其他结算要求", TextUtils.isEmpty(datas.getOtherSettlementRequire())?"/":datas.getOtherSettlementRequire()+"  "));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_THREE));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_TWO, "运费开票信息", ""));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"单位名称", TextUtils.isEmpty(datas.getInvoicingCompanyName())?"/":datas.getInvoicingCompanyName()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"税号", TextUtils.isEmpty(datas.getInvoicingTaxNumber())?"/":datas.getInvoicingTaxNumber()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"地址", TextUtils.isEmpty(datas.getInvoicingAddress())?"/":datas.getInvoicingAddress()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"企业电话", TextUtils.isEmpty(datas.getInvoicingCompanyPhone())?"/":datas.getInvoicingCompanyPhone()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"开户银行", TextUtils.isEmpty(datas.getInvoicingBank())?"/":datas.getInvoicingBank()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"银行账号", TextUtils.isEmpty(datas.getInvoicingBankAccount())?"/":datas.getInvoicingBankAccount()));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"开户行行号", TextUtils.isEmpty(datas.getInvoicingBankNumber())?"/":datas.getInvoicingBankNumber()));
    }
    private void setOtherAgreements(List<SingleItemEntity> list, GoodsSourceDetail datas){
        list.clear();
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"甲方责任约定", TextUtils.isEmpty(datas.getPartyDuty())?"/":datas.getPartyDuty()+"  "));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"乙方责任约定", TextUtils.isEmpty(datas.getSecondPartyDuty())?"/":datas.getSecondPartyDuty()+"  "));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"违约约定", TextUtils.isEmpty(datas.getRenegePromise())?"/":datas.getRenegePromise()+"  "));
        list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,"合同终止约定", TextUtils.isEmpty(datas.getEndContractPromise())?"/":datas.getEndContractPromise()+"  "));
        if (datas.getDiyField()!=null){
            for (int i = 0;i<datas.getDiyField().size();i++){
                list.add(new SingleItemEntity(SingleItemConstant.TYPE_ONE,datas.getDiyField().get(i).getKey(), datas.getDiyField().get(i).getValue()));
            }
        }
    }
    /**
     * 初始化功能列表
     */
    public void initSettingItem( List<AddressItem> list, GoodsSourcePlace mgoodsSourcePkace,String handleTypeNo) {
        if (list == null) return;
        list.clear();
        if ("11".equals(handleTypeNo)){//一装一卸
            list.add(new AddressItem(mgoodsSourcePkace.getProvinceName()+"  "+mgoodsSourcePkace.getCityName()+"  "+mgoodsSourcePkace.getDistrictName(),mgoodsSourcePkace.getDetailAddress(),mgoodsSourcePkace.getFirstDistance(),true, R.mipmap.icon_load_goods,handleTypeNo,0));
            list.add(new AddressItem(mgoodsSourcePkace.getDestProvinceName()+"  "+mgoodsSourcePkace.getDestCityName()+"  "+mgoodsSourcePkace.getDestDistrictName(),mgoodsSourcePkace.getDestDetailAddress(),null,false, R.mipmap.icon_unload_goods,handleTypeNo,1));
        }else if ("12".equals(handleTypeNo)){//一装两卸
            list.add(new AddressItem(mgoodsSourcePkace.getProvinceName()+"  "+mgoodsSourcePkace.getCityName()+"  "+mgoodsSourcePkace.getDistrictName(),mgoodsSourcePkace.getDetailAddress(),mgoodsSourcePkace.getFirstDistance(),true, R.mipmap.icon_load_goods,handleTypeNo,0));
            list.add(new AddressItem(mgoodsSourcePkace.getViaDestProvinceName()+"  "+mgoodsSourcePkace.getViaDestCityName()+"  "+mgoodsSourcePkace.getViaDestDistrictName(),mgoodsSourcePkace.getViaDestDetailAddress(),mgoodsSourcePkace.getSecondDistance(),true, R.mipmap.icon_unload_one,handleTypeNo,1));
            list.add(new AddressItem(mgoodsSourcePkace.getDestProvinceName()+"  "+mgoodsSourcePkace.getDestCityName()+"  "+mgoodsSourcePkace.getDestDistrictName(),mgoodsSourcePkace.getDestDetailAddress(),null,false, R.mipmap.icon_unload_two,handleTypeNo,2));
        }else if ("21".equals(handleTypeNo)){//两装一卸
            list.add(new AddressItem(mgoodsSourcePkace.getProvinceName()+"  "+mgoodsSourcePkace.getCityName()+"  "+mgoodsSourcePkace.getDistrictName(),mgoodsSourcePkace.getDetailAddress(),mgoodsSourcePkace.getFirstDistance(),true, R.mipmap.icon_load_one,handleTypeNo,0));
            list.add(new AddressItem(mgoodsSourcePkace.getViaSendProvinceName()+"  "+mgoodsSourcePkace.getViaSendCityName()+"  "+mgoodsSourcePkace.getViaSendDistrictName(),mgoodsSourcePkace.getViaSendDetailAddress(),mgoodsSourcePkace.getSecondDistance(),true, R.mipmap.icon_load_two,handleTypeNo,1));
            list.add(new AddressItem(mgoodsSourcePkace.getDestProvinceName()+"  "+mgoodsSourcePkace.getDestCityName()+"  "+mgoodsSourcePkace.getDestDistrictName(),mgoodsSourcePkace.getDestDetailAddress(),null,false, R.mipmap.icon_unload_goods,handleTypeNo,2));
        }else if ("22".equals(handleTypeNo)){
            list.add(new AddressItem(mgoodsSourcePkace.getProvinceName()+"  "+mgoodsSourcePkace.getCityName()+"  "+mgoodsSourcePkace.getDistrictName(),mgoodsSourcePkace.getDetailAddress(),mgoodsSourcePkace.getFirstDistance(),true, R.mipmap.icon_load_one,handleTypeNo,0));
            list.add(new AddressItem(mgoodsSourcePkace.getViaSendProvinceName()+"  "+mgoodsSourcePkace.getViaSendCityName()+"  "+mgoodsSourcePkace.getViaSendDistrictName(),mgoodsSourcePkace.getViaSendDetailAddress(),mgoodsSourcePkace.getSecondDistance(),true, R.mipmap.icon_load_two,handleTypeNo,1));
            list.add(new AddressItem(mgoodsSourcePkace.getViaDestProvinceName()+"  "+mgoodsSourcePkace.getViaDestCityName()+"  "+mgoodsSourcePkace.getViaDestDistrictName(),mgoodsSourcePkace.getViaDestDetailAddress(),mgoodsSourcePkace.getThirdDistance(),true, R.mipmap.icon_unload_one,handleTypeNo,2));
            list.add(new AddressItem(mgoodsSourcePkace.getDestProvinceName()+"  "+mgoodsSourcePkace.getDestCityName()+"  "+mgoodsSourcePkace.getDestDistrictName(),mgoodsSourcePkace.getDestDetailAddress(),null,false, R.mipmap.icon_unload_two,handleTypeNo,3));
        }
    }
    private String messagePrice(GoodsSourceDetail goodsSourceDetail){
        return goodsSourceDetail.getFreight()==null?"0": NumberUtil.trim0(goodsSourceDetail.getFreight());
    }
    private String allFreight(BaseViewHolder helper,GoodsSourceDetail goodsSourceDetail){
        return goodsSourceDetail.getFreightType()==null||goodsSourceDetail.getFreightType()==0? (goodsSourceDetail.getAllFreight()==null||goodsSourceDetail.getFreightUnit()==null?"0": NumberUtil.trim0(goodsSourceDetail.getAllFreight()) + setFreightUnit(helper,goodsSourceDetail.getFreightUnit())):goodsSourceDetail.getFreightTypeWorlds();
    }
    private String setFreightUnit(BaseViewHolder helper,Integer freightUnit){
        String string = "";
        if (freightUnit==null){
            return "";
        }
        if (freightUnit==1){
            string="元";
        }else if (freightUnit==2){
            string="元";
        }else if (freightUnit==3){
            string="元";
        }else {
            string="";
        }
        return string;
    }
    //打电话弹窗
    public void showConsignorDialog(String phone) {
        new RoundDialog.Builder(mContext)
                .title("确认呼叫")
                .content(phone)
                .cancel("取消")
                .confirm("确定")
                .contentGravity(Gravity.CENTER)
                .cancelable(false)
                .confirmCallback(new RoundDialog.SingleCallback() {
                    @Override
                    public void onClick(View v) {
                        if(flowLog!=null) {
                            LogisticsLogUtils.getInstance().logisticsFlow(flowLog);
                        }
                        callPhone(phone);
                    }
                })
                .show();
    }
    protected void callPhone(String phoneNum) {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        Uri data = Uri.parse("tel:" + phoneNum);
        intent.setData(data);
        startActivity(intent);
    }
    private boolean isLogin() {
        return !TextUtils.isEmpty(SharedPreferenceUtil.getInstance().
                getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""));
    }
}
